package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Classinfo;
import cn.wolfcode.mapper.ClassinfoMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IClassinfoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ClassfoServiceImpl implements IClassinfoService {

    @Autowired
    private ClassinfoMapper classinfoMapper;


    @Override
    public void deleteByPrimaryKey(Long id) {
        classinfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Classinfo classinfo) {
        return classinfoMapper.insert(classinfo);
    }

    @Override
    public Classinfo selectByPrimaryKey(Long id) {
        return classinfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Classinfo> selectAll() {
        return classinfoMapper.selectAll();
    }

    @Override
    public void updateByPrimaryKey(Classinfo record) {
        classinfoMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageInfo query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Classinfo> classinfos = classinfoMapper.selectForList(qo);
        System.out.println(classinfos);
        return new PageInfo<Classinfo>(classinfos);
    }
}
